<template>
  <div class="NavBar">
    <img
      class="arrow"
      src="~@/assets/images/navbar/left_arrow.png"
      alt=""
      @click="back"
    />
    <p>{{ title }}</p>
    <img v-if="showIcon" :class="[isEdit ? editClass : iconClass, '']" :src="icons[logo]" alt="" />
  </div>
</template>

<script>
import star from '@/assets/images/navbar/star.png'
import share from '@/assets/images/navbar/share2x.png'
import search from '@/assets/images/navbar/search.png'
import edit from '@/assets/images/navbar/edit.png'

export default {
  data() {
    return {
      icons: {
        star,
        share,
        search,
        edit
      },
      editClass: 'edit',
      iconClass: 'icon'
    }
  },
  props: {
    title: {
      type: String,
    },
    logo: {
      type: String,
      default: '',
    },
  },
  computed: {
    showIcon() {
      if (this.logo.length === 0) {
        return false
      }

      return true
    },
    isEdit() {
      if (this.logo === 'edit') {
        return true
      }

      return false
    }
  },
  methods: {
    back() {
      this.$router.go(-1)
    },
  },
}
</script>

<style lang="scss" scoped>
.NavBar {
  display: flex;
  width: 750px;
  height: 45px;
  background-color: transparent;
  font-size: 32px;
  text-align: center;
  line-height: 45px;
  color: #ffffff;
  margin-top: 20px;

  .arrow {
    margin-left: 40px;
    margin-top: 20px;
    width: 15px;
    height: 30px;
  }
  p {
    width: 618px;
    margin-top: 15px;
    font-weight: bold;
    text-align: center;
  }
  .icon {
    margin-top: 15px;
    width: 40px;
    height: 40px;
  }
  .edit {
    width: 80px;
    height: 40px;
    margin-top: 15px;
    margin-right: 40px;
  }
}
</style>
